#include <stdio.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main()
 {
 int n,j;
 scanf("%d",&n);
 for(j==0;j<n;j++){
 
	
	int a,b,c,i;
	scanf("%d%d%d",&a ,&b, &c);
	

	for(i=10;i<=100;i++)
	{
		if(i%3==a&&i%5==b&&i%7==c){
	    printf("%d",i);
		break;

	    }
	    if(i==101){
	    
	
		printf("no answer.\n");}
		
		
	}

}
}
